package abc.reflect

import android.app.Application
import android.content.Context
import android.graphics.Bitmap
import kotlinx.coroutines.script.tes.appBuildTime
import kotlinx.coroutines.script.tes.appDeviceId
import kotlinx.coroutines.script.tes.initializeApp
import kotlinx.coroutines.script.tes.phoneScreenHeight
import kotlinx.coroutines.script.tes.phoneScreenWidth


class App: Application() {
    override fun onCreate() {
        super.onCreate()
        instance = this
        initializeApp(this)
        System.loadLibrary("app")
        setupNative(this, appDeviceId, appBuildTime)
    }

    external fun takePixel(bitmap: Bitmap, x: Int, y: Int): Int
    external fun isSimilarColor(redA: Int, greenA: Int, blueA: Int, redB: Int, greenB: Int, blueB: Int, offsetRed: Int, offsetGreen: Int, offsetBlue: Int): Boolean
    external fun pointToAngle(x: Int, y: Int): Int
    external fun angleToPoint(originX: Float, originY: Float, angle: Int, length: Int, screenWidth: Float = phoneScreenWidth.toFloat(), screenHeight: Float = phoneScreenHeight.toFloat()): Pair<Float, Float>
    private external fun setupNative(context: Context, deviceId: String, buildTime: Long): Int
    companion object {
        private var instance: App? = null
        fun take(): App = instance!!
    }
}